<?php
session_start();
if ($_SESSION['Status'] != '1') {
    header('Location: signup.php');
}
$id = $_SESSION['name'];

include 'dbconnection.php';

$query = "SELECT * FROM users WHERE email = '$id'";
$result2 = mysql_query($query);
$record = mysql_fetch_array($result2);

$f_name = $record['f_name'];
$l_name = $record['l_name'];
$email = $record['email'];
$c_name = $record['c_name'];
$country = $record['country'];
?>

<div class="page">
    <div class="padding10">
        <h2><b class="fg-color-blueDark"><?php echo $f_name . " " . $l_name ?></b></h2>
    </div>
    <div class="page snapped" >
        <div class="page-region">
            <div class="page-region-content">
                <div class="clearfix">
                    <div class="tile image" id="profile-pic">
                        <div class="tile-content">
                            <img src="img/user.png" />
                        </div>
                        <div class="brand">
                            <div class="badge">
                                <i class="icon-pencil" id="edit_Pic"></i>
                                <script>
                                    $(document).ready(function(){
                                        $('#edit_Pic').click(function(e) {
                                            $.Dialog({
                                                'title'      : 'Change Profile Picture',
                                                'draggable'  : true,
                                                'content'    :  '<form id="p_pic"> <input type="file" name="photo">'+
                                                                '<p><input name="mybtn" type="submit" value="Upload" /></p> </form>',
                                                'buttons'    : {
                                                    'Ok'     : {
                                                        'action': function() {
                                                            var data_acyr = $('#p_pic').serialize();
                                                            $.ajax({
                                                                url:'imageupload.php',
                                                                type:"POST",
                                                                data: data_acyr,
                                                                success:function(data){
                                                                    alert('uploaded');
                                    
                                                                }
                                                            });
                                                        }
                                                    },
                                                    'Cancel'     : {
                                                        'action': function() {}
                                                    }
                                                }
                                            });
                                        });
                                    });
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
                <div style="width: 250px;">
                    <blockquote class="tertiary-text padding10 bg-color-white" style="margin-bottom: 10px;">&nbsp;<b>About</b><i class="icon-pencil place-right fg-color-lighten" id="editProfile"></i></blockquote>
                    <blockquote class="tertiary-text padding10 bg-color-white" style="margin-bottom: 10px;"><i class="icon-mail"></i>&nbsp;E-mail<b class="fg-color-blue"><?php echo " " . $email ?></b></blockquote>
                    <script>
                        $(document).ready(function(){
                            $('#editProfile').click(function(e) {
                                $.Dialog({
                                    'title'      : 'Edit Your Profile',
                                    'draggable': true,
                                    'content'    : '<form id="edit_profile"><table style="border-color: white;">'+
                                        '<tr><td><p><label>E-mail:</label></td><td><input class="with-helper input-control text" name="email" type="text" autofocus="" placeholder="ex: 2012/2013"/></p></td></tr>'+
                                        '<tr><td><p><label>User Type:</label></td><td><select type="text" autofocus="" name="type" placeholder=""><option value="Student">Student</option><option value="Teacher">Teacher</option></select></p></td></tr>'+
                                        '<tr><td><p><label>Institute:</label></td><td><input class="with-helper input-control text" type="text" autofocus="" name="college" placeholder=""/></p></td></tr>'+
                                        '<tr><td><p><label>country/Region:</label></td><td><input class="with-helper input-control text" type="text" autofocus="" name="country" placeholder=""/></p></td></tr>'+
                                        '<tr><td><p><label>Description:</label></td><td><input class="with-helper input-control text" name="desc" type="text" autofocus="" placeholder=""/></p></td></tr>'+
                                        '</table></form>',
                                    'buttons'    : {
                                        'Ok'    : {
                                            'action': function() {
                                                var data_acyr = $('#edit_profile').serialize();
                                                $.ajax({
                                                    url:'profileConfig.php?action=UPDATE',
                                                    type:"POST",
                                                    data: data_acyr,
                                                    success:function(data){
                                    
                                                    }
                                                });
                                            }
                                        },
                                        'Cancel'     : {
                                            'action': function() {}
                                        }
                                    }
                                });
                            });
                        });
                    </script>
                    <blockquote class="tertiary-text padding10 bg-color-white" style="margin-bottom: 10px;"><i class="icon-user-2"></i>&nbsp;Is a <b class="fg-color-blue">User type</b></blockquote>
                    <blockquote class="tertiary-text padding10 bg-color-white" style="margin-bottom: 10px;"><i class="icon-home"></i>&nbsp;At<b class="fg-color-blue"><?php
if ($c_name == "") {
    echo '&nbsp' . 'Edit College';
} else {
    echo '&nbsp' . $c_name;
}
?></b></blockquote>
                    <blockquote class="tertiary-text padding10 bg-color-white" style="margin-bottom: 10px;"><i class="icon-location-3"></i>Located in<b class="fg-color-blue"><?php
                            if ($c_name == "") {
                                echo " " . 'Edit Country';
                            } else {
                                echo " " . $country;
                            }
?></b></blockquote>
                </div>
            </div>
        </div>
    </div>
    <!-- include sidebar.php if needed -->
    <div class="page fill">
        <div class="page-region">
            <div class="page-region-content">
                <div class="grid">
                    <div class="row">
                        <div class="tile double bg-color-lighten">
                            <div class="tile-content">

                            </div>
                            <div class="brand">
                                <div class="name">
                                    Groups
                                </div>
                            </div>
                        </div>
                        <div class="tile double bg-color-lighten">
                            <div class="tile-content">

                            </div>
                        </div>
                        <div class="padding10"><p>User's Statisticals</p></div>
                        <div class="tile double double-vertical bg-color-lighten">
                            <div class="tile-content">

                            </div>
                            <div class="brand">
                                <div class="name">
                                    Groups
                                </div>
                            </div>
                        </div>
                        <div class="tile double double-vertical bg-color-lighten">
                            <div class="tile-content">

                            </div>
                            <div class="brand">
                                <div class="name">
                                    Groups
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
